package com.meishij.customerview;

import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListenerAdapter;
import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.meishij.R;

import static android.content.ContentValues.TAG;
import static android.util.Log.e;

/**
 * Created by Administrator on 2016/10/14.
 * 我是youngKaka 我的心愿是世界和平
 */

public class FloatiingActionBehavior extends FloatingActionButton.Behavior {

    public FloatiingActionBehavior() {
    }

    public FloatiingActionBehavior(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) {
        //开始滑动的监听  scrollAxes 滑动的方向
        child.hide();
        return true;
    }

    @Override
    public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
        if (dyConsumed < 0) {
            child.show();
        } else {
            child.hide();
        }
        super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
    }

    @Override
    public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target) {
        child.show();
        super.onStopNestedScroll(coordinatorLayout, child, target);
    }
}
